import java.util.Scanner;

class User {
    private String name;
    private long password;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getPassword() {
        return password;
    }

    public void setPassword(long password) {
        this.password = password;
    }

    public User(String name, long password) {
        this.name = name;
        this.password = password;
    }
}

public class test1 {

    //判断是否用户名出错
    private static void isUserName(User user, String name) throws UserNameException {
        if(!user.getName().equals(name)) {
            throw new UserNameException("用户名输入错误！");
        }
    }

    private static void isUserPassword(User user, long password) throws UserPasswordException {
        if(user.getPassword() != password) {
            throw new UserPasswordException("用户密码输入错误！");
        }
    }
    private static void login(User user) throws UserNameException, UserPasswordException {
        System.out.println("请输入用户名称：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        System.out.println("请输入用户密码：");
        long pass = scanner.nextLong();

        isUserName(user,name);

        isUserPassword(user, pass);

        System.out.println("登录成功");
    }
    public static void main(String[] args) throws UserNameException, UserPasswordException {
        User user = new User("花花", 141017);
        login(user);
    }
}
